<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="../style/journal.css" type="text/css" />
<style type="text/css"><!--
.googleadsense {
	margin: 2px;
	padding: 0px;
//--></style><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-65008-1";
urchinTracker();
</script><title>Day [05.4.23] stay with me</title>
</head>
<body>
<a href="index.html">Journal</a>(2005) | <a href="../blog/"><b>Blog</b></a>(2006) | <a href="http://www.fayland.org/cgi-bin/random_link.pl">RandomLink</a> | <a href="AboutFayland.html">WhoAmI</a> | <a href="LiveBookmark.html">LiveBookmark</a> | <a href="http://www.fayland.org/">HomePage</a>
<p><&lt;Previous: <a href="parrot_glossary.html">Parrot 术语</a>&nbsp;&nbsp;>>Next: <a href="Eplanet.html">Eplanet</a></p>
<h1>Day [05.4.23] stay with me</h1>
<div class='content'>
<p>Category: <a href='Diary.html'>Diary</a> &nbsp; Keywords: <b>catalyst</b></p><p>早上去上考研数学微积分，下午闲着无事改代码。</p>

<p>先改改了留言本 FayGuestBook，因为 $q-&gt;param('name1') 不能变量内插，所以就用了 $q-&gt;Vars</p>


<pre>my %input = $q-&gt;Vars;</pre>


<p>变量少的时候可以用 my $name1 = $q-&gt;param('name1');，可变量一多写起来就麻烦了。不过可以试试下面的代码</p>


<pre>
my ($name1, $name2, $name3, $name4, $name5, $name6);
foreach (qw/name1 name2 name3 name4 name5 name6/) {
    no strict 'refs';
    ${$_} = $q-&gt;param($_);
}
</pre>


<p>这样也不是非常好。不过暂时也想不出什么好办法来。<br />
留言本实在不想大改，没啥意思。将它移植到 <a href="http://www.fayland.org/guestbook/">fayland.org GuestBook</a> 就不想管了。</p>

<p>接着去看 Eplanet 的代码。<br />
Eplanet 有个功能(build_alltopics)是将数据库里的数据转为 <span class="caps">HTML </span>文档。</p>


<pre>
my @cms = Eplanet::M::CDBI::Cms-&gt;retrieve_all;
	
foreach (0 .. $#cms) {
    $c-&gt;stash-&gt;{topic} = $cms[$_];
    $c-&gt;stash-&gt;{prev_topic} = $cms[$_-1] unless ($_ == 0);
    $c-&gt;stash-&gt;{next_topic} = $cms[$_+1] unless ($_ == $#cms);
    $c-&gt;stash-&gt;{build_filename} = $cms[$_]-&gt;get('cms_file');

    $c-&gt;req-&gt;action(undef);$c-&gt;res-&gt;output(undef);

    $c-&gt;req-&gt;path('view/'. $cms[$_]-&gt;{'cms_id'} .'/build');
    $c-&gt;prepare_action();
    $c-&gt;dispatch();
}
</pre>


<p>用 path, prepare_action, dispatch 来执行多次 view，这功能改自 Catalyst::Plugin::SubRequest<br />
多次执行 view 的速度实在让人不太能忍受。于是想着在 mod_perl 下运行。<br />
运行不成功，倒是找到了个 bug，给 Catalyst Maillist 组发了 mail:<br />
<a href="http://lists.rawmode.org/pipermail/catalyst/2005-April/000285.html" lang="bug">$req-&gt;base 's trailing slash in Catalyst::Engine::CGI</a></p>

<p>运行不成功的提示是</p>


<pre>Caught exception &quot;DBD::mysql::db FETCH failed: handle 2 is owned by thread 138b014 not current thread 2d1b40c (handles can't be shared between threads and your driver may need a CLONE method added) at C:/usr/site/lib/Ima/DBI.pm line 316.&quot;</pre>


<p>可能需要重新启动机子或者其他的吧。这个容后再考虑。</p>

<p>晚上再看会代码，然后去喝点酒。</p>

<h2>22:00</h2>
搞不定那个多线程错误，只好转向运行 catalyst 生成的一个 http 服务器（用 catalyst Eplanet 命令后，在script目录下有一个eplanet_server.pl）。发现速度很让人惊讶。将它转为 bat 文件（改下use lib）后放到 path 目录下。OK.</div>
<p><&lt;Previous: <a href="parrot_glossary.html">Parrot 术语</a>&nbsp;&nbsp;>>Next: <a href="Eplanet.html">Eplanet</a></p>
<p><strong>Options:</strong> <a href='http://del.icio.us/post?title=Day%20%5B05.4.23%5D%20stay%20with%20me&url=http://www.fayland.org/journal/050423.html'>+Del.icio.us</a></p>
<strong>Related items</strong>
<ul><li><a href='050328.html'>Catalyst & Eplanet</a> < <span class='digit'>2005-03-28 13:19:19</span> ></li><li><a href='Catalyst_Authenticate.html'>Catalyst Authenticate</a> < <span class='digit'>2005-09-26 12:50:39</span> ></li><li><a href='Catalyst_Flaw.html'>Catalyst 的一个不足（一个已去掉）</a> < <span class='digit'>2005-09-27 13:44:31</span> ></li><li><a href='Catalyst_Session_Win32.html'>Catalyst 在 Win32 下的 Session</a> < <span class='digit'>2005-09-29 11:08:04</span> ></li><li><a href='Catalyst_NoFavIcon.html'>Catalyst && favicon.ico</a> < <span class='digit'>2005-09-30 00:57:57</span> ></li><li><a href='Catalyst_Overview.html'>我对 Catalyst 的理解和介绍</a> < <span class='digit'>2005-10-08 01:39:40</span> ></li><li><a href='Catalyst_XMLRPC.html'>Catalyst && XML-RPC</a> < <span class='digit'>2005-10-11 21:50:30</span> ></li><li><a href='Catalyst_YAML.html'>Catalyst config YAML</a> < <span class='digit'>2005-12-10 12:50:39</span> ></li><li><a href='CatalystAdventCalendar_CN.html'>Catalyst Advent Calendar 中文版</a> < <span class='digit'>2005-12-15 23:28:40</span> ></li></ul>
Created on <span class="digit">2005-04-23 16:17:02</span>, Last modified on <span class="digit">2005-04-24 22:20:49</span><br />
Copyright 2004-2005 All Rights Reserved. Powered by <a href="Eplanet.html">Eplanet</a> && <a href='http://catalyst.perl.org'>Catalyst</a> 5.62.
</body>
</html>